<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>nih: nih::cuda::Kd_builder&lt; Integer &gt; Struct Template Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nih
   &#160;<span id="projectnumber">0.5</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('structnih_1_1cuda_1_1_kd__builder.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">nih::cuda::Kd_builder&lt; Integer &gt; Struct Template Reference<div class="ingroups"><a class="el" href="group__kdtree.html">k-d Trees</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="nih::cuda::Kd_builder" -->
<p><code>#include &lt;<a class="el" href="kd__builder_8h_source.html">kd_builder.h</a>&gt;</code></p>

<p><a href="structnih_1_1cuda_1_1_kd__builder-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memTemplParams" colspan="2">template&lt;typename OutputTree , typename Iterator &gt; </td></tr>
<tr><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structnih_1_1cuda_1_1_kd__builder.html#a227e02ff324dfb9c251fee6954e942c8">build</a> (OutputTree &amp;out_tree, thrust::device_vector&lt; uint32 &gt; &amp;out_index, const <a class="el" href="structnih_1_1_bbox.html">Bbox3f</a> bbox, const Iterator points_begin, const Iterator points_end, const uint32 max_leaf_size)</td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa620524c7d26050cd6713b2fd619ed45"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_codes" ref="aa620524c7d26050cd6713b2fd619ed45" args="" -->
thrust::device_vector&lt; Integer &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>m_codes</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aadd42d7e987727d8d480debfecc8e2fe"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_levels" ref="aadd42d7e987727d8d480debfecc8e2fe" args="[64]" -->
uint32&#160;</td><td class="memItemRight" valign="bottom"><b>m_levels</b> [64]</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a96b9aebcce9a59a0c9bfe82d973ce547"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_bbox" ref="a96b9aebcce9a59a0c9bfe82d973ce547" args="" -->
<a class="el" href="structnih_1_1_bbox.html">Bbox3f</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_bbox</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adfbb54bfad7dc7176f6d87585a1ab29c"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_node_count" ref="adfbb54bfad7dc7176f6d87585a1ab29c" args="" -->
uint32&#160;</td><td class="memItemRight" valign="bottom"><b>m_node_count</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a43a932652753fed10014c39973e5ac2c"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_leaf_count" ref="a43a932652753fed10014c39973e5ac2c" args="" -->
uint32&#160;</td><td class="memItemRight" valign="bottom"><b>m_leaf_count</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a158d2483ee18b23b53c9b1b5e9e55106"></a><!-- doxytag: member="nih::cuda::Kd_builder::m_kd_context" ref="a158d2483ee18b23b53c9b1b5e9e55106" args="" -->
<a class="el" href="structnih_1_1cuda_1_1_bintree__gen__context.html">cuda::Bintree_gen_context</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_kd_context</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename Integer&gt;<br/>
struct nih::cuda::Kd_builder&lt; Integer &gt;</h3>

<p>GPU-based middle-split k-d tree builder</p>
<p>This class provides the context to generate k-d trees on the GPU starting from a set of unordered points. The output is a set of nodes with the corresponding leaves and a set of primitive indices into the input set of points. The output leaves will specify contiguous ranges into this index.</p>
<dl><dt><b>Template Parameters:</b></dt><dd>
  <table class="">
    <tr><td class="paramname">Integer</td><td>an integer type that determines the number of bits used to compute the points' Morton codes. Accepted values are uint32 and uint64.</td></tr>
    <tr><td class="paramname">OutputTree</td><td>a template class used to write the output tree, with the following interface:</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>OutputTree
 {
    <span class="keywordtype">void</span> reserve_nodes(<span class="keyword">const</span> uint32 n);  <span class="comment">// reserve space for n nodes</span>
    <span class="keywordtype">void</span> reserve_leaves(<span class="keyword">const</span> uint32 n); <span class="comment">// reserve space for n leaves</span>

    Context get_context();             <span class="comment">// get a context to write nodes/leaves</span>

    <span class="keyword">struct </span>Context
    {
        <span class="keywordtype">void</span> write_node(
           <span class="keyword">const</span> uint32 node,          <span class="comment">// node to write</span>
           <span class="keyword">const</span> uint32 offset,        <span class="comment">// child offset</span>
           <span class="keyword">const</span> uint32 skip_node,     <span class="comment">// skip node</span>
           <span class="keyword">const</span> uint32 begin,         <span class="comment">// node range begin</span>
           <span class="keyword">const</span> uint32 end,           <span class="comment">// node range end</span>
           <span class="keyword">const</span> uint32 split_index,   <span class="comment">// split index</span>
           <span class="keyword">const</span> uint32 split_dim,     <span class="comment">// splitting dimension</span>
           <span class="keyword">const</span> uint32 split_plane);  <span class="comment">// splitting plane</span>

        <span class="keywordtype">void</span> write_node(
           <span class="keyword">const</span> uint32 node,          <span class="comment">// node to write</span>
           <span class="keyword">const</span> uint32 offset,        <span class="comment">// child offset</span>
           <span class="keyword">const</span> uint32 skip_node,     <span class="comment">// skip node</span>
           <span class="keyword">const</span> uint32 begin,         <span class="comment">// node range begin</span>
           <span class="keyword">const</span> uint32 end);          <span class="comment">// node range end</span>

        <span class="keywordtype">void</span> write_leaf(
           <span class="keyword">const</span> uint32 index,         <span class="comment">// leaf to write</span>
           <span class="keyword">const</span> uint32 begin,         <span class="comment">// leaf range begin</span>
           <span class="keyword">const</span> uint32 end);          <span class="comment">// leaf range end</span>
    };
 };
</pre></div><p>The following code snippet shows how to use this builder:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #include &lt;<a class="code" href="kd__builder_8h.html" title="Interface for a middle-split CUDA-based k-d tree builder.">nih/kd/cuda/kd_builder.h</a>&gt;</span>
<span class="preprocessor"> #include &lt;<a class="code" href="kd__context_8h.html" title="Define basic k-d tree context structure.">nih/kd/cuda/kd_context.h</a>&gt;</span>

 thrust::device_vector&lt;Vector3f&gt; points;
 ... <span class="comment">// code to fill the input vector of points</span>

 thrust::device_vector&lt;Kd_node&gt;  kd_nodes;
 thrust::device_vector&lt;uint2&gt;    kd_leaves;
 thrust::device_vector&lt;uint32&gt;   kd_index;

 <a class="code" href="structnih_1_1cuda_1_1_kd__builder.html">nih::cuda::Kd_builder&lt;uint64&gt;</a> builder( kd_index );
 <a class="code" href="structnih_1_1cuda_1_1_kd__context.html">nih::cuda::Kd_context</a> kd_tree( &amp;kd_nodes, &amp;kd_leaves, NULL );
 builder.build(
     kd_tree,                                    <span class="comment">// output tree</span>
     kd_index,                                   <span class="comment">// output index</span>
     Bbox3f( Vector3f(0.0f), Vector3f(1.0f) ),   <span class="comment">// suppose all bboxes are in [0,1]^3</span>
     points.begin(),                             <span class="comment">// begin iterator</span>
     points.end(),                               <span class="comment">// end iterator</span>
     4 );                                        <span class="comment">// target 4 objects per leaf</span>
</pre></div> </div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a227e02ff324dfb9c251fee6954e942c8"></a><!-- doxytag: member="nih::cuda::Kd_builder::build" ref="a227e02ff324dfb9c251fee6954e942c8" args="(OutputTree &amp;out_tree, thrust::device_vector&lt; uint32 &gt; &amp;out_index, const Bbox3f bbox, const Iterator points_begin, const Iterator points_end, const uint32 max_leaf_size)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Integer &gt; </div>
<div class="memtemplate">
template&lt;typename OutputTree , typename Iterator &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="structnih_1_1cuda_1_1_kd__builder.html">nih::cuda::Kd_builder</a>&lt; Integer &gt;::build </td>
          <td>(</td>
          <td class="paramtype">OutputTree &amp;&#160;</td>
          <td class="paramname"><em>out_tree</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">thrust::device_vector&lt; uint32 &gt; &amp;&#160;</td>
          <td class="paramname"><em>out_index</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structnih_1_1_bbox.html">Bbox3f</a>&#160;</td>
          <td class="paramname"><em>bbox</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Iterator&#160;</td>
          <td class="paramname"><em>points_begin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Iterator&#160;</td>
          <td class="paramname"><em>points_end</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint32&#160;</td>
          <td class="paramname"><em>max_leaf_size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>build a bvh given a set of points that will be reordered in-place</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">out_tree</td><td>output tree </td></tr>
    <tr><td class="paramname">out_index</td><td>output index </td></tr>
    <tr><td class="paramname">bbox</td><td>global bbox </td></tr>
    <tr><td class="paramname">points_begin</td><td>beginning of the point sequence to sort </td></tr>
    <tr><td class="paramname">points_end</td><td>end of the point sequence to sort </td></tr>
    <tr><td class="paramname">max_leaf_size</td><td>maximum leaf size </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this struct was generated from the following files:<ul>
<li>kd/cuda/<a class="el" href="kd__builder_8h_source.html">kd_builder.h</a></li>
<li>kd/cuda/<a class="el" href="kd__builder__inline_8h_source.html">kd_builder_inline.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>nih</b>      </li>
      <li class="navelem"><b>cuda</b>      </li>
      <li class="navelem"><a class="el" href="structnih_1_1cuda_1_1_kd__builder.html">Kd_builder</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Thu Dec 15 2011 11:56:22 for nih by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
